<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;
use think\Session;
use app\admin\controller\Admin;

 
class Flow extends Admin
{

    public function index()
    {   
        $data = $this->flowSee();
        return view('admin@flow/index',[
            'data'=>$data
        ]);
    }

    public function allFlow()
    {
        return view('admin@flow/allFlow');
    }

    public function endFlow()
    {
        return view('admin@flow/endFlow');
    }

    public function flowSee($flow_status='1')
     {
        $username = Session::get('admin_user')['username'];
        if ($username == 'admin') {
            $data = db('role_flow')->select();
        }else{
            $uid = db('user')->field('id')->where(['username'=>$username])->find();
            $rid = db('user_role')->field('rid')->where(['uid'=>$uid['id']])->select();
            foreach ($rid as  $v) {
                $flowname[] = db('role_flow')->where(['role_id'=>$v['rid']])->find();
            }
            foreach ($flowname as  $v) {
                if($v == null){
                    continue;
                }
                $data[] = $v;
            }
        }
       return $data;
     }

}